<?php

//require_once 'configAPI.php';

//function publicaTablon($touid, $token, $msg, $title, $uri, $desc, $pic, $action_name,  $action_link){
/*function publicaTablon($touid, $token, $msg, $title, $uri, $desc, $pic, $action_name,  $action_link){
	if ( ($touid !="") && ($token !="") && ($msg != "") && ($title != "") && ($uri != "") && ($desc != "") && ($pic != "") && ($action_name != "") && ($action_link != "") ) {
	//$touid=$me["id"];
	
	$url = "https://graph.facebook.com/".$touid."/feed";
	//$url = "https://graph.facebook.com/me/feed";
	$attachment =  array(
	'access_token' => $token,
	'message' => $msg,
	'name' => $title,
	'link' => $uri,
	'description' => $desc,
	'picture'=>$pic,
	'actions' => json_encode(array('name' => $action_name,'link' => $action_link))
	);
	
	// set the target url
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL,$url);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
	curl_setopt($ch, CURLOPT_POST, true);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  //to suppress the curl output
	//print_r($ch);
	$result = curl_exec($ch);
	curl_close ($ch);
	return $result;
	} else {
	return 0;
	}
}
*/


//mensajeUsuario aparece cómo si o hubiese escrito el propio usuario. Desaconsejo su uso.
/*function publica($mensajeUsuario, $tituloPub, $subtituloPub, $enlaceTitulo, $texto, $urlImg){
$attachment = array
 (
 'access_token'=>$facebook->getAccessToken(),
 'message' => 'Sergio esta probandoooo',
 'name' => 'murumudvi',
 'caption' => 'aaaaaaa',
 'link' => 'http://apps.facebook.com/moodvie/',
 'description' => 'yaeah',
 'picture' => 'http://supergaia.fdi.ucm.es:8060/moodvie/imagenes/vineta.png'
 );
 $result = $facebook->api($me["id"].'/feed/','post',$attachment);
}*/

function publicaPeli($uid, $facebook, $tituloPeli, $enlaceTitulo, $texto, $urlImg){
	
$texto="Moodvie me recomienda: " . $tituloPeli;
$attachment = array
 (
 'access_token'=> $facebook->getAccessToken(),
 'message' => '',
 'name' => $texto,
 'caption' => 'Recomendación de películas basadas en temperamento',
 'link' => $enlaceTitulo,
 'description' => $texto,
 'picture' => $urlImg
 );
 $result = $facebook->api($uid.'/feed/','post',$attachment);
}

?>